# 定义编译器和编译选项
CXX = g++
CXXFLAGS = -Wall -g -Isrc -Isrc/Eigen

# 定义源文件和可执行文件
PROBLEMS = src/solve/Problem1.cpp src/solve/Problem2.cpp src/solve/Problem3.cpp src/solve/Problem4.cpp src/solve/Problem5.cpp src/solve/ProblemA.cpp src/solve/ProblemD.cpp
EXECUTABLES = $(PROBLEMS:.cpp=)

# 定义 report 的相关文件
REPORT = doc/report.tex 
DESIGN = doc/design.tex

# 默认目标
.PHONY: all
all:  report design run

# 运行所有的 Problem 代码
.PHONY: run
run: $(EXECUTABLES)
	./src/solve/Problem1.exe
	./src/solve/Problem2.exe
	./src/solve/Problem3.exe
	./src/solve/Problem4.exe
	./src/solve/Problem5.exe
	./src/solve/ProblemA.exe
	./src/solve/ProblemD.exe
	
# 编译 report.tex 生成 PDF
.PHONY: report
report: $(REPORT)
	pdflatex $(REPORT)
	pdflatex $(REPORT)

# 编译 design.tex 生成 PDF
.PHONY: design
design: $(DESIGN)
	pdflatex $(DESIGN)
	pdflatex $(DESIGN)

# 编译每个 Problem 文件
$(EXECUTABLES): %: %.cpp 
	$(CXX) $(CXXFLAGS) $< -o ./$@

# 清理生成的文件
.PHONY: clean
clean:
	del *.pdf *.log *.aux
	del src\solve\*.exe 
	